import Vue from 'vue'
import Router from 'vue-router'
import Layout from '@/layout'

Vue.use(Router)

export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    redirect: '/home',
    children: [
      {
        path: 'home',
        name: 'home',
        component: () => import('@/views/home/index'),
        meta: { title: '首页' }
      },
    ]
  },
  {
    path: '/base',
    name: 'base',
    component: Layout,
    redirect: '/apimgr',
    meta: { title: '基础配置' },
    children: [
      {
        path: 'apimgr',
        name: 'apimgr',
        component: () => import('@/views/base/apimgr'),
        meta: { title: 'API注册' }
      },
      {
        path: 'tieFunction',
        name: 'tieFunction',
        component: () => import('@/views/base/tieFunction'),
        meta: { title: '方法注册' }
      },
      {
        path: 'localAop',
        name: 'localAop',
        component: () => import('@/views/base/localAop'),
        meta: { title: '本地触发' }
      },
    ]
  },
  {
    path: '/module',
    name: 'module',
    component: Layout,
    redirect: '/k3cloudurl',
    meta: { title: '组件' },
    children: [
      {
        path: 'k3cloudurl',
        name: 'k3cloudurl',
        component: () => import('@/views/module/k3cloudurl'),
        meta: { title: 'K3CLOUD请求' }
      },
      {
        path: 'localurl',
        name: 'localurl',
        component: () => import('@/views/module/localurl'),
        meta: { title: '本地请求' }
      },
      {
        path: 'paramhandle',
        name: 'paramhandle',
        component: () => import('@/views/module/paramhandle'),
        meta: { title: '参数处理' }
      },
      {
        path: 'paramif',
        name: 'paramif',
        component: () => import('@/views/module/paramif'),
        meta: { title: '条件判断' }
      },
    ]
  },
  {
    path: '/errorinfo',
    name: 'errorinfo',
    component: Layout,
    redirect: '/todo',
    meta: { title: '异常处理' },
    children: [
      {
        path: 'done',
        name: 'done',
        component: () => import('@/views/errorinfo/done'),
        meta: { title: '已处理' }
      },
      {
        path: 'ignore',
        name: 'ignore',
        component: () => import('@/views/errorinfo/ignore'),
        meta: { title: '已忽略' }
      },
      {
        path: 'todo',
        name: 'todo',
        component: () => import('@/views/errorinfo/todo'),
        meta: { title: '待处理' }
      },
    ]
  },
  {
    path: '/log',
    name: 'log',
    component: Layout,
    redirect: '/flowlog',
    meta: { title: '日志' },
    children: [
      {
        path: 'flowlog',
        name: 'flowlog',
        component: () => import('@/views/log/flowlog'),
        meta: { title: '流程日志' }
      },
    ]
  },
  {
    path: '/biz',
    name: 'biz',
    component: Layout,
    redirect: '/flow',
    meta: { title: '业务' },
    children: [
      {
        path: 'flow',
        name: 'flow',
        component: () => import('@/views/biz/flow'),
        meta: { title: '流程' }
      },
    ]
  },
  {
    path:'/workshopManagement',
    name:'workshopManagement',
    component: Layout,
    redirect:'/workshopManagement',
    meta:{title:'车间管理'},
    children: [
      {
        path:'workshop',
        name:'workshop',
        component: () =>import('@/views/workshopManager/workShop'),
        meta:{title:'车间'}
      },
    ]
  },

  {
    path:'/dataManager',
    name:'dataManager',
    component: Layout,
    redirect:'/dataManager',
    meta:{title:'数据管理'},
    children: [
      {
        path:'passwordManager',
        name:'passwordManager',
        component: () =>import('@/views/dataManager/passwordManager'),
        meta:{title:'密码管理'}
      },
      {
       path:'idManager',
        name:'idManager',
        component: ()=>import('@/views/dataManager/idManager'),
        meta:{title:'账户管理'}
      }
    ]
  },
  {
    path: '/xuTest',
    name: 'xuTest',
    component: Layout,
    redirect: '/xuTest',
    meta: {title: '测试12'},
    children: [

      {
        path: 'xuTest2',
        name: 'xuTest2',
        component: () => import('@/views/customer/xuTest2'),
        meta: {title: '测试子菜单2'}
      }

    ]
  },
  {
    path: '/materialTest',
    name: 'materialTest',
    component: Layout,
    redirect: '/materialTest',
    meta: {title: '物品资料'},
    children: [
      {
        path: 'xuMaterial',
        name: 'xuMaterial',
        component: () => import('@/views/materialTest/xuMaterial'),
        meta: {title:'物料包装'}
      },
      {
        path: 'xuMaPack',
        name: 'xuMaPack',
        component: () => import('@/views/materialTest/xuMaPack'),
        meta: {title: '物料'}
      },
      {
        path: 'xuMaterialGroup',
        name: 'xuMaterialGroup',
        component: () => import('@/views/materialTest/xuMaterialGroup'),
        meta: {title: '物料分组'}
      }

    ]
  },
  {
    path: '/xjfSimpleWork',
    name: 'xjfSimpleWork',
    component: Layout,
    redirect: '/xjfSimpleWork',
    meta: {title: '简单生产_jf'},
    children: [
      {
        path: 'xuWorkOrder',
        name: 'xuWorkOrder',
        component: () => import('@/views/xjfSimpleWork/xuWorkOrder'),
        meta: {title:'生产订单_jf'}
      },
      {
        path: 'xuReqMaterial',
        name: 'xuReqMaterial',
        component: () => import('@/views/xjfSimpleWork/xuReqMaterial'),
        meta: {title: '生产领料_jf'}
      },
      {
        path: 'xuReport',
        name: 'xuReport',
        component: () => import('@/views/xjfSimpleWork/xuReport'),
        meta: {title: '生产汇报_jf'}
      },
      {
        path: 'xuInStore',
        name: 'xuInStore',
        component: () => import('@/views/xjfSimpleWork/xuInStore'),
        meta: {title: '生产入库_jf'}
      }
    ]
  },

  {
    path: '/psyManage',
    name: 'psyManage',
    component: Layout,
    redirect: '/psyManage',
    meta: {title: '设备管理'},
    children: [
      {
        path: 'psy',
        name: 'psy',
        component: () => import('@/views/psyManage/psy'),
        meta: {title: '设备资料'},

      },
      {
        path:'group',
        name:'group',
        component:() => import('@/views/psyManage/group'),
        meta:{title:'设备分组'},
      }
    ]
  },
  {
    path:'/basedataManager',
    name:'basedataManager',
    component:Layout,
    meta:{title:'资料管理'},
    children: [
      {
        path:'tsyu',
        name:'tsyu',
        component:() => import('@/views/basedataManager/tsyu'),
        meta:{title:'辅助资料'},
      },
      {
        path:'productGroup',
        name:'productGroup',
        component:() => import('@/views/basedataManager/productGroup'),
        meta:{title:'资料分组'},
      }
    ]
  },
  //注塑模具
  {
    path: '/mouldManage',
    name:'mouldManage',
    component:Layout,
    redirect:'/mouldManage',
    meta:{title:'注塑模具'},
    children:[
      {
        path:'injectionMold',
        name:'injectionMold ',
        component:()=>import ('@/views/injectionMold/injectionMoldOne/injectionMoldThreeList'),
        meta:{title:'注塑模具One'}
      },
      {
        path:'injectionMoldTwo',
        name:'injectionMoldTwo',
        component:()=>import ('@/views/equipment/category/equipmentGroup'),
        meta:{title:'注塑模具Two'}
      },
      {
        path:'injectionMoldThree',
        name:'injectionMoldThree',
        component:()=>import ('@/views/equipment/material/material'),
        meta:{title:'注塑模具Three'}
      }
    ]
  },

  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

export function resetRouter () {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
